package com.hongye.backstage.controller;

import com.hongye.backstage.entity.HomeyBuyEntity;
import com.hongye.backstage.service.HomeyBuyService;
import com.hongye.common.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @progam:hongye-house
 * @author:GJS
 * @Time:2022/4/28 19:00
 */
@RestController
@RequestMapping("/backstage/buy")
public class HomeyBuyController {
    @Autowired
    private HomeyBuyService homeyBuyService;

    /**
     * 我想买个房
     * @param homeyBuyEntity
     * @return
     */
    @RequestMapping("/addHomeyBuy")
    public ResponseResult addHomeyBuy(@RequestBody HomeyBuyEntity homeyBuyEntity){
        ResponseResult<Integer> result = new ResponseResult<>();
        Integer i = homeyBuyService.addHomeyBuy(homeyBuyEntity);
        if (i>0){
            result.setCode(200);
            result.setData(i);
            return result;
        }else {
            result.setCode(500);
            result.setData(i);
            return result;
        }
    }
}
